package com.chinanet.service.manager;

import com.chinanet.entry.manager.Article;
import com.chinanet.entry.manager.Defect;
import com.chinanet.repository.manager.ArticleRepository;
import com.chinanet.repository.manager.DefectRepository;
import com.chinanet.service.manager.imp.IDefectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class DefectServiceImpl implements IDefectService {

    @Autowired
    private DefectRepository defectRepository;

    @Autowired
    private ArticleRepository articleRepository;

    /**
     * @param defect
     * @param article
     * @return
     */
    @Override
    @Transactional
    public long saveDefectAndArticle(Defect defect, Article article) {
        defect.setArticleId(articleRepository.save(article).getId());
        return defectRepository.save(defect).getId();
    }
}